<!DOCTYPE html>
<!--suppress ThymeleafVariablesResolveInspection-->
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="Responsive Admin Dashboard Template">
    <meta name="keywords" content="admin,dashboard">
    <meta name="author" content="skcats">
    <title></title>
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}" media="all" />
</head>
<style>
    .layui-table-page {
        text-align: center;
    }
    .utable .layui-laypage .layui-laypage-curr .layui-laypage-em {
        background-color: #1E9FFF;
    }
    .layui-table-view thead th {
        text-align: center;
        font-weight: bold;
    }
    .layui-table {
        text-align: center;
        margin-top: -10px;
    }
    .layui-table-view tbody td {
        text-align: center;
    }
</style>
<body>
<div>
    <!--    当前选择对象id-->
    <input type="hidden" id="id" th:value="${session.empid}">
</div>
<!--数据表格样式及附件-->
<script type="text/html" id="bar">
    {{#  if(d.image === null){ }}
    <a id="ann" class="layui-btn layui-btn-warm layui-btn-xs" lay-event="upload">
        <i class="layui-icon">&#xe642;</i>上传图片
    </a>
    {{#  } else { }}
    <a class="layui-btn layui-btn-xs" lay-event="look">
        <i class="layui-icon">&#xe642;</i>查看图片
    </a>
    {{#  } }}
    <a id="upd" class="layui-btn layui-btn-xs" lay-event="upd">
        <i class="layui-icon">&#xe642;</i>编辑
    </a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">
        <i class="layui-icon">&#xe640;</i>丢弃
    </a>
</script>
<!--数据表格样式及附件-->
<script id="toolbarDemo" type="text/html">
    <div class="layui-btn-container">
        <a onclick="javascript:history.back(-1);">
            <i class="layui-icon" style="font-size: 20px;padding-right: 10px;cursor: pointer;">&#xe65c;</i>
        </a>
        <button id="add" class="layui-btn layui-btn-sm"><i class="layui-icon">&#xe624;</i>新增</button>
    </div>
</script>
<!--数据表格  数据表格使用的是方法渲染-->
<div class="utable">
    <!--表格-->
    <table class="layui-table" id="tab" lay-filter="tab"></table>
</div>
</body>
<script th:src="@{/assets/plugins/jquery/jquery-3.1.0.min.js}"></script>
<script th:src="@{/layui/layui.js}"></script>
<script type="text/javascript" th:inline="none">
    layui.use('table', function () {
        var table = layui.table;
        var id = $('#id').val();
        //方法渲染
        table.render({
            elem: '#tab'
            ,id: 'tab'
            ,height: 500
            ,width: 1250
            ,url: '/option/assess?id='+id //数据接口
            ,page: true //开启分页
            ,toolbar: '#toolbarDemo'
            ,cols: [[ //表头
                {field: 'aduitname', title: '考核内容'}
                ,{field: 'empname', title: '员工姓名'}
                ,{field: 'scores', title: '考核分数'}
                ,{field: 'auditperson', title: '录入人员'}
                ,{field: 'auditdate', title: '考核时间'}
                ,{field: 'remark', title: '说明'}
                ,{fixed: 'right', title:'操作', toolbar: '#bar',width:250}
            ]]
        });

        //点击添加iframe窗方法
        $("#add").on('click',function(){
            //iframe窗
            layer.open({
                type: 2,
                title: '考核录入新增',
                maxmin: true, //开启最大化最小化a按钮
                area: ['430px', '320px'],
                content: ['/aduitlog/toadd']//这是链接你的页面地址 url
            });
        })
        //监听行工具事件
        table.on('tool(tab)', function (obj) {
            var data = obj.data;
            //console.log(obj)
            if (obj.event === 'del') {
                layer.confirm('真的删除么?', function (index) {
                    obj.del();
                    layer.close(index);
                    $.ajax({
                        url: '/aduitlog/del',
                        type: 'post',
                        data: {
                            id:data.aduitlogid
                        },
                        dataType: 'json',
                        success:function(data){
                            if(data){
                                layer.msg(JSON.stringify("删除成功"));
                            }else {

                            }
                        },
                    })
                });
            }else if (obj.event == 'upd') {//修改

                layer.open({
                    type: 2,
                    title: '考核录入修改',
                    maxmin: true, //开启最大化最小化a按钮
                    area: ['430px', '320px'],
                    content: ['/aduitlog/toupd?id='+data.aduitlogid]//这是链接你的页面地址 url
                });

            }else if (obj.event == 'upload') {//上传

                layer.open({
                    type: 2,
                    title: '图片上传',
                    maxmin: true, //开启最大化最小化a按钮
                    area: ['400px', '360px'],
                    content: ['/aduitlog/toupload?id='+data.aduitlogid]//这是链接你的页面地址 url
                });

            }else if (obj.event == 'look') {//查看
                layer.open({
                    type: 2,
                    title: '图片查看',
                    maxmin: true, //开启最大化最小化a按钮
                    area: ['650px', '500px'],
                    content: ['/aduitlog/tolook?id='+data.aduitlogid]//这是链接你的页面地址 url
                });

            }

        })
    });
</script>
</html>